package model;

/**
 * The Point class has two coodinates, x and y, and provides methods to change these
 * coordinates via a difference (delta).
 *
 */
public class Point {
	
	private int x;
	private int y;
	
	public Point(final int x, final int y){
		this.setX(x);
		this.setY(y);
	}
	public void move(final int deltaX, final int deltaY){
		this.setX(this.getX() + deltaX);
		this.setY(this.getY() + deltaY);
	}
	public int getX() {
		return x;
	}
	private void setX(final int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	private void setY(final int y) {
		this.y = y;
	}
	/**
	 * Provides true if this {@link Point} is not outside of the provided {@link RectangularArea}.
	 * @param area is a {@link RectangularArea}.
	 * @return true if this {@link Point} is not outside of the provided {@link RectangularArea}. Else false.
	 */
	public boolean isIn(final RectangularArea area){
		return   this.getX() <= area.getLeftUpperCorner().getX() &&
				 this.getX() >= area.getRightUpperCorner().getX() &&
				 this.getY() <= area.getLeftUpperCorner().getY() &&
				 this.getY() >= area.getLeftLowerCorner().getY();
	}
	@Override
	public String toString(){
		return "[X: " + this.getX() + ", Y: " + this.getY() + "]";
	}
	@Override
	public boolean equals(final Object obj) {
		final Point other = (Point) obj;
		return this.x == other.x && this.y == other.y;
	}
}
